﻿using System;

namespace diantou.web.enterprise
{
    /// <summary>
    /// 企业用户考试权限视图
    /// </summary>
    /// <typeparam name="viewType"></typeparam>
    abstract class examView<viewType> : view<viewType>
        where viewType : examView<viewType>
    {
        /// <summary>
        /// 考试
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        protected diantou.examDataAccess.exam exam;
        /// <summary>
        /// 修改状态
        /// </summary>
        protected bool isReworkTitle
        {
            get { return exam.Id == 0; }
        }
        /// <summary>
        /// 修改状态
        /// </summary>
        protected bool isReworkStartTime
        {
            get { return exam.Id == 0; }
        }
        /// <summary>
        /// 修改状态
        /// </summary>
        protected bool isReworkEndTime
        {
            get { return exam.Id == 0; }
        }
        /// <summary>
        /// 修改状态
        /// </summary>
        protected bool isReworkMaxMinutes
        {
            get { return exam.Id == 0; }
        }
        /// <summary>
        /// 评审人员是否存在查看页面权限
        /// </summary>
        protected virtual bool isReviewUserPage
        {
            get { return false; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="examId"></param>
        /// <returns></returns>
        protected bool load(int examId, string searchEnginePath = null)
        {
            if (examId == 0)
            {
                checkSearchEngine(searchEnginePath, webConfig.NotFound404);
                return false;
            }
            exam = diantou.examDataAccess.clientCache.GetExam(examId, currentUser, isReviewUserPage);
            if (exam != null) return true;
            AjaxResponse(webConfig.NotFound404);
            return false;
        }
    }
}
